﻿@model IEnumerable<BlogKickStart.Models.Post> /*New*/

 @{
	ViewBag.Title = "Index";
	Layout = "~/Views/Shared/_Layout.cshtml";
}
@*<script type="text/javascript">
		document.write("<link href=\"&#64;");
		document.write("Url.Content('~/Content/");
		@ViewBag.themeName
		document.write(".css')' rel='stylesheet' type='text/css'/>");
</script>*@

<script language="javascript">
	function toggle(postId) {
		var ele = document.getElementById("Editor" + postId);
		if (ele.style.display == "block") {
			ele.style.display = "none";
		}
		else {
			ele.style.display = "block";
		}


		var xmlhttp = new XMLHttpRequest();
		xmlhttp.onreadystatechange = function () {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				ele.innerHTML = xmlhttp.responseText;
			}
		}
		
		xmlhttp.open("GET", "HTMLEditor.txt", true);
		xmlhttp.send();
		
	}

</script>
<div class="pageDiv">
@{
	<span>Pages:</span>
	for (int x = 0; x <= ViewBag.pages; x++)
	{
		if(ViewBag.page == x)
		{
			<span class="currentpagenum">@x.ToString()</span>
		}
		else
		{
			<span class="pagenum">@Html.ActionLink(x.ToString(), "Index", new { page = x }) </span>
		}
	}	
	
}
</div>

@foreach (var item in Model)
{
	<article>
		<h2 class="BlogTitle">@item.Title</h2>
		<p class="PostTimeStamp">@item.Date</p>
		<section>
			@Html.Raw(item.MarkedContent)
		</section>	

		<div class="editnavbar"> 
			<ul class="navlist"> 
					<li><em>
						@Html.ActionLink("Edit Post", "EditPost", new { postID = @item.PostID })</em></li> 
					<li><em>
						@Html.ActionLink("New Post", "EditPost")
					</em></li>
			</ul> 
		</div>

	<div class="commentDiv">
		
		@foreach (var comment in @item.Comments)
		  {
			 
			<p class="PostTimeStamp">@comment.CommentDate</p>
			<div class="comment">
				@Html.Raw(comment.MarkedContent)
				
			</div>
 
		  }
	</div>
	<div class = "editnavbar">
		<ul class="navlist"> 
			<li><em>
				@Html.ActionLink("Comment", "Comment", new { postID = @item.PostID })
			</em></li>
		</ul>
	</div>
	</article>
}
<br />

<div class="pageDiv">
@{
	<span>Pages:</span>
	for (int x = 0; x <= ViewBag.pages; x++)
	{
		if (ViewBag.page == x)
		{
			<span class="currentpagenum">@x.ToString()</span>
		}
		else
		{
			<span class="pagenum">@Html.ActionLink(x.ToString(), "Index", new { page = x }) </span>
		}
	}	
	
}
		

</div>